#include "StdAfx.h"
#include "UIClip.h"


CUIClip::CUIClip( HDC hDC ): m_hDC( hDC ), m_hRgn( NULL ), m_hOldRgn( NULL )
{
    m_hOldRgn =::CreateRectRgn( 0, 0, 1, 1 );
    ::GetClipRgn( hDC, m_hOldRgn );
    m_hRgn =::CreateRectRgn( 0, 0, 1, 1 );
}


CUIClip::~CUIClip( void )
{
    ::SelectClipRgn( m_hDC, m_hOldRgn );
    ::DeleteObject( m_hRgn );
    ::DeleteObject( m_hOldRgn );
}

void CUIClip::AddRect( const RECT& rcClip, int iRgnMode )
{
    HRGN hRgn =::CreateRectRgnIndirect( &rcClip );
// 	RECT rc;
// 	::GetClipBox(m_hDC,&rc);
//  	HRGN hRgn1=::CreateRectRgnIndirect(&rc);
//  	int iCom=::CombineRgn(m_hRgn,hRgn,hRgn1,iRgnMode);
//  	::SelectClipRgn(m_hDC,m_hRgn);
    ::ExtSelectClipRgn( m_hDC, hRgn, iRgnMode );
    ::DeleteObject( hRgn );
//	::DeleteObject(hRgn1);
}
